package day3;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

/**2018-03-25
 * 输入一个生产日期格式"yyyy-MM-dd",再输入一个数字(保质期的天数)。
 * 然后经过计算输出促销日期，促销日期为:该商品过期日前2周的周三
 * @author Bonnie
 *
 */
public class Test04 {
    public static void main(String[] args) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入生产日期，输入格式为:yyyy-MM-dd");
        String s = scanner.nextLine();
        System.out.println("保质期天数：");
        int day = scanner.nextInt();
        long times=24*60*60*1000;
        Date s1=sdf.parse(s);
        Date date=new Date();
        long time=date.getTime();
        long days=time/times;
        long time1=s1.getTime()+times*day;
        Date date1=new Date(time1);
        System.out.println("商品过期日期为："+sdf.format(date1));
        long p1 = time1 - (times * 11);
        Date p2 = new Date(p1);
        System.out.println("促销日期为："+sdf.format(p2));




    }
}
